using FireStarterModeller.BO;

namespace FireStarterModeller.Test
{
    public static class TestUtilsDMPropertyType
    {
        /// <summary>
        /// Creates a new saved DMPropertyType with a random value assigned to every property
        /// </summary>
        public static DMPropertyType CreateSavedStringPropertyType()
        {
            DMPropertyType dMPropertyType = CreateUnsavedStringPropertyType();
            dMPropertyType.Save();
            return dMPropertyType;
        }

        /// <summary>
        /// Creates a new saved DMPropertyType with a random value assigned to every property
        /// </summary>
        public static DMPropertyType CreateSavedDMPropertyType()
        {
            DMPropertyType dMPropertyType = CreateUnsavedValidDMPropertyType();
            dMPropertyType.Save();
            return dMPropertyType;
        }

        /// <summary>
        /// Creates a new unsaved DMPropertyType with a random value assigned to every property
        /// </summary>
        public static DMPropertyType CreateUnsavedStringPropertyType()
        {
            DMPropertyType dMPropertyType = new DMPropertyType {AssemblyName = "System", PropertyTypeName = "String"};
            return dMPropertyType;
        }

        /// <summary>
        /// Creates a new unsaved DMPropertyType with a random value assigned to every property
        /// </summary>
        public static DMPropertyType CreateUnsavedValidDMPropertyType()
        {
            DMPropertyType dMPropertyType = new DMPropertyType
                    {
                        AssemblyName = TestUtilsShared.GetRandomString(),
                        PropertyTypeName = TestUtilsShared.GetRandomString()
                    };

//			dMPropertyType.SolutionID = TestUtilsShared.CreateSavedDMSolution().SolutionID;
            return dMPropertyType;
        }

        /// <summary>
        /// Creates a new unsaved DMPropertyType where all properties are null, except ID properties
        /// and those with default values.  If there are compulsory properties without
        /// defaults, saving the object will throw an exception.
        /// </summary>
        public static DMPropertyType CreateUnsavedDefaultDMPropertyType()
        {
            DMPropertyType dMPropertyType = new DMPropertyType();
            return dMPropertyType;
        }

        public static DMPropertyType CreateSavedBooleanPropertyType()
        {
            DMPropertyType dMPropertyType = new DMPropertyType();
            dMPropertyType.AssemblyName = "System";
            dMPropertyType.PropertyTypeName = "Boolean";
            return dMPropertyType;
        }

        public static DMPropertyType CreateSavedIntPropertyType()
        {
            DMPropertyType dMPropertyType = new DMPropertyType();
            dMPropertyType.AssemblyName = "System";
            dMPropertyType.PropertyTypeName = "Int32";
            return dMPropertyType;
        }

        public static DMPropertyType CreateSavedDateTimePropertyType()
        {
            DMPropertyType dMPropertyType = new DMPropertyType();
            dMPropertyType.AssemblyName = "System";
            dMPropertyType.PropertyTypeName = "DateTime";
            return dMPropertyType;
        }

        public static DMPropertyType CreateDMProperty(string assemblyName, string typeName) {
            DMPropertyType dMPropertyType = new DMPropertyType();
            dMPropertyType.AssemblyName = assemblyName;
            dMPropertyType.PropertyTypeName = typeName;
            return dMPropertyType;
        }
    }
}